<template>
  <div id="app">
    <h1>根组件{{count}}</h1>
    <input :value="count" type="text">
    <add-item></add-item>
    <hr>
    <sub-item></sub-item>
  </div>
</template>

<script>
import AddItem from './components/add-item.vue'
import SubItem from './components/sub-item.vue'
import {mapState} from 'vuex';

export default {
  name: 'app',
  data: function () {
    return {
      
    }
  },
  components: {
    AddItem,
    SubItem
  },
  computed:{

    //mapState辅助函数使用的步骤
    //1.导入辅助函数
    //2.在计算属性中调用并展开结果
    ...mapState(['count'])
  }
}
</script>

<style>
#app {
  width: 600px;
  margin: 20px auto;
  border: 3px solid #ccc;
  border-radius: 3px;
  padding: 10px;
}
</style>